import { Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
import { Message } from './message.entity';

@Entity()
export class Session {
  @PrimaryGeneratedColumn('uuid', { comment: '会话主键' })
  id: string;

  @Column({ comment: '会话名称', type: 'varchar' })
  name: string;

  @Column({ comment: '用户id' })
  userId: number;

  @CreateDateColumn({ comment: '创建时间', type: 'datetime' })
  createTime: Date;

  @UpdateDateColumn({ comment: '最后更新时间', type: 'datetime' })
  updateTime: Date;

  @Column({ comment: '会话状态 0 开启 1 关闭', type: 'tinyint' })
  status: number = 0;

  @Column({ comment: '是否删除 0 未删除  1删除', type: 'tinyint' })
  isDelete: number = 0;

  @OneToMany(() => Message, (message) => message.session)
  messages: Message[];
}
